package org.reach.springframework;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 尹志远
 * @desc
 * @Date 2024/2/4 10:04
 */
public class BeanFactory {
    private static final BeanFactory INSTANCE = new BeanFactory();

    public static BeanFactory getInstance() {
        return INSTANCE;
    }

    private BeanFactory() {
    }

    private Map<String, BeanDefinition> beanMap = new ConcurrentHashMap<>();

    public Object getBean(String name) {
        return beanMap.get(name).getBean();
    }

    public void registerBeanDefinition(String name,BeanDefinition beanDefinition){
        beanMap.put(name,beanDefinition);
    }
}
